<script type="">

    $(document).ready(function(){                    
        $("#open_pop,#open_pop_2").colorbox({inline:true,width:"450px", height:"200px",opacity:0.1,onLoad: function(){  
                $('#cboxClose').remove();              
            }        
        });                

    });
    
    function edit_mode(id){
        $('#edit_id').val(id);            
        $('#category_name_edit').val($('#category_name_'+id).html());        
        $('#category_description_edit').val($('#category_des_'+id).html());    
    }    

    function update_category(){
        var id = $('#edit_id').val();
        if(id == 0){
            var category_name = $('#category_name').val();       
            var category_description = $('#category_description').val();                          
        }else{
            var category_name = $('#category_name_edit').val();       
            var category_description = $('#category_description_edit').val();                       
        }        

        if(category_name == ''){
            alert('Bạn chưa nhập tên cho chủ đề!');return false;
        }

        var strUrl = '<?=$url->createUrl("project/ajaxUpdateCategory") ?>';            
        loadingAjax();
        $.ajax({
            type: "GET",
            url: strUrl,
            data: {id:id,category_name:category_name,category_description:category_description},
            success: function(msg){                            
                if(msg==1){                       
                    location.reload();   
                }
            }
        });

        closeLoadingAjax();
    }

    function delete_category(category_id){
        if(confirm('Bạn có chắc chắn muốn xóa?')){
            var strUrl = '<?=$url->createUrl("project/ajaxDeleteCategory") ?>';            
            loadingAjax();
            $.ajax({
                type: "GET",
                url: strUrl,
                data: {category_id:category_id},
                success: function(msg){                            
                    if(msg==1){                       
                        $('#category_row_'+category_id).hide('slow');
                    }
                }
            });

            closeLoadingAjax();            
        }
    }

</script>